﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace Spencen.Mobile.UI.Primitives
{
    public class RegularPolygonElement : PolygonElement
    {
        public RegularPolygonElement()
        {
            NumberOfSides = 6; // Defaults to a hexagon
        }

        public int NumberOfSides { get; set; }

        protected override Point[] GeneratePoints()
        {
            var points = new Point[ NumberOfSides ];

            var startAngle = 0.0f;
            var angleDelta = (float) Math.PI * 2.0f / NumberOfSides;
            var radiusX = Size.Width / 2;
            var radiusY = Size.Height / 2;
            for ( int index = 0; index < NumberOfSides; index++ )
            {
                points[ index ] = new Point( RelativeCenter.X + (int) ( radiusX * Math.Cos( startAngle ) ), RelativeCenter.Y + (int) ( radiusY * Math.Sin( startAngle ) ) );
                startAngle += angleDelta;
            }

            return points;
        }
    }
}
